package cn.tedu._05mvcboot03.base.response;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @Author Justin Parker
 * @Date 2024/8/13 0013 16:26
 * @Version 1.0
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {

    @ApiModelProperty(value = "状态码")
    private Integer state;
    @ApiModelProperty(value = "状态信息")
    private String message;
    @ApiModelProperty(value = "响应结果")
    private Object data;


    public  JsonResult(StatusCode statusCode) {
        this.state = statusCode.getState();
        this.message = statusCode.getMessage();
    }

    public  JsonResult(StatusCode statusCode, Object data) {
        this.state = statusCode.getState();
        this.message = statusCode.getMessage();
        this.data = data;
    }


    public static JsonResult ok(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult ok() {
        return JsonResult.ok(null);
    }
}
